package com.szbmyoubao.app.view.dialog

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import com.szbmyoubao.app.bean.StatusItem
import com.szbmyoubao.app.helper.VideoHelper
import com.ellecity06.common.base.BaseDialogFragment
import com.ellecity06.common.ktx.load
import com.ellecity06.common.ktx.toast
import com.ellecity06.cwhiskymall.databinding.DialogReportBinding

/**
 * @author ellecity06
 * @time 2025/3/21 16:26
 * @des
 */

class ReportDialog(val url: String ?=null,val  isVideo: Boolean) : BaseDialogFragment<DialogReportBinding>() {
    override fun inflateBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): DialogReportBinding {
        return DialogReportBinding.inflate(inflater, container, false)
    }

    private val statusList =
        mutableListOf(
            StatusItem(name = "政治敏感", type = null),
            StatusItem(name = "内容低俗", type = 1),
            StatusItem(name = "骚扰广告", type = 0),
            StatusItem(name = "其他", type = 0)
        )

    override fun initialize() {
        if (isVideo&&url!=null){
            lifecycleScope.launchWhenStarted {
                val videoFirstFrame = VideoHelper.Companion.getVideoFirstFrame(url)
                binding.iv.setImageBitmap(videoFirstFrame)
//                videoFirstFrame?.recycle()
            }

        }else {
            binding.iv.load(requireActivity(),url)
        }
        binding.tvDgcCancel.setOnClickListener {
            dismiss()
        }
        binding.tvSelect.setOnClickListener {

        }
        binding.tvDgcConfirm.setOnClickListener {
            val text = binding.etCode.text.toString().trim()
            if (text.isEmpty()) {
                toast("内容不可为空")
                return@setOnClickListener
            }
            toast("提交成功")
            dismiss()

        }

    }
}